// 定义初始状态
const defaultState = {
    count: 0
};

// 修改状态
const changState = (action) => {
    switch (action.type) {
    case 'increment':
        defaultState.count++;
        break;
    case 'decrement':
        defaultState.count--;
        break;
    default:
    }
};

// DOM 操作
const renderDom = () => {
    document.querySelector('#count').innerHTML = defaultState.count;
};


const dispatch = (action) => {
    changState(action);
    renderDom();
};

export {
    defaultState,
    dispatch
};
